<!DOCTYPE HTML>
<html xmlns:th="http://www.thymeleaf.org">
<head>

    <title>APP开发者平台</title>

    <!-- jquery -->
    <script type="text/javascript" th:src="@{/js/jquery.min.js}"></script>
    <!-- bootstrap -->
    <link rel="stylesheet" type="text/css" th:href="@{/bootstrap/css/bootstrap.min.css}" />
    <script type="text/javascript" th:src="@{/bootstrap/js/bootstrap.min.js}"></script>
    <!-- jquery-validator -->
    <script type="text/javascript" th:src="@{/jquery-validation/jquery.validate.min.js}"></script>
    <script type="text/javascript" th:src="@{/jquery-validation/localization/messages_zh.min.js}"></script>
    <!-- layer -->
    <script type="text/javascript" th:src="@{/layer/layer.js}"></script>
    <!-- md5.js -->
    <script type="text/javascript" th:src="@{/js/md5.min.js}"></script>
    <!-- common.js -->
    <script type="text/javascript" th:src="@{/js/common.js}"></script>


    <!-- Font Awesome -->
    <link th:href="@{/css/font-awesome.min.css}" rel="stylesheet">
    <!-- NProgress -->
    <link th:href="@{/css/nprogress.css}" rel="stylesheet">

    <!-- Custom Theme Style -->
    <link th:href="@{/css/custom.min.css}" rel="stylesheet">
<!--    <script type="text/javascript" th:src="@{/static/js/common.js}" />
    <script type="text/javascript" th:src="@{/static/js/layer/layser.js}" />-->
</head>

<body>
    <form align="center" id="loginForm">
        <h1 align="center">APP开发者平台</h1>
        <div class="form-group" align="center">
            <div class="row">
                <div class="col-md-4"></div>

                <label class="form-label col-xs-1">请输入用户名</label>
                <div class="col-xs-3">
                    <input id="devCode" name = "devCode" class="form-control" type="text" placeholder="用户名" required="true"  minlength="5" maxlength="11" />
                </div>

                <div class="col-md-1">
                </div>
            </div>
        </div>


        <div class="form-group">
            <div class="row" align="center">

                <div class="col-md-4"></div>
                <label class="form-label  col-xs-1">请输入密码</label>
                <div class="col-xs-3">
                    <input id="devPassword" name="devPassword" class="form-control" type="password"  placeholder="密码" required="true" minlength="6" maxlength="16" />
                </div>

                <div class="col-md-1"></div>
            </div>
        </div>
        <div class="row">
            <div class="col-md-4"></div>
        </div>


        <div class="row" align="center">
            <div class="col-md-4"></div>
            <div class="col-md-2">
                <button class="btn btn-primary btn-block" type="reset" onclick="reset()">重置</button>
            </div>
            <div class="col-md-2">
                <button class="btn btn-primary btn-block" type="submit" onclick="doLogin()">登录</button>
            </div>
            <div class="col-md-4"></div>
        </div>

    </form>
</body>


<script>
    function login(){
        $("#loginForm").validate({
            submitHandler:function(form){
                doLogin();
            }
        });
    }
    function doLogin() {
        g_showLoading();

        var devCode = $("#devCode").val();
        var devPassword = $("#devPassword").val();
        $.ajax({
            url: "/dev/doLogin",
            type: "POST",
            data:{
                devCode :devCode,
                devPassword:devPassword
            },
            success:function (data) {
                layer.closeAll();
                if(data.code == 0){
                    alert("登录成功！");
                    //layer.msg("成功！");
                    window.location.href="/developer/main";
                }else {
                    alert(data.msg);
                }
            },
            error:function(){
                layer.closeAll();
            }
        });
    }
</script>
</html>